package com.mcc.app.msg.controller;

import java.util.Date;
import java.util.List;
import com.mcc.common.utils.SecurityUtils;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mcc.common.annotation.Log;
import com.mcc.common.core.controller.BaseController;
import com.mcc.common.core.domain.AjaxResult;
import com.mcc.common.enums.BusinessType;
import com.mcc.app.msg.domain.MsgRemind;
import com.mcc.app.msg.service.IMsgRemindService;
import com.mcc.common.core.page.TableDataInfo;

/**
 * 消息提醒
 *
 * @author gxy
 * @date 2023-12-05
 */
@Api(tags = "消息提醒")
@RestController
@RequestMapping("/msg/remind")
public class MsgRemindController extends BaseController {

    @Autowired
    private IMsgRemindService msgRemindService;

    @ApiOperation("查询消息提醒列表")
    @ApiOperationSupport(order = 1)
    @GetMapping("/list")
    public AjaxResult<TableDataInfo<MsgRemind>> list(MsgRemind msgRemind) {
        List<MsgRemind> list = msgRemindService.selectMsgRemindList(msgRemind);
        return getDataTable(list);
    }

    @ApiOperation("查询消息提醒列表(分页)")
    @ApiOperationSupport(order = 2)
    @GetMapping("/page")
    public AjaxResult<TableDataInfo<MsgRemind>> page(MsgRemind msgRemind) {
        startPage();
        List<MsgRemind> list = msgRemindService.selectMsgRemindList(msgRemind);
        return getDataTable(list);
    }

    @ApiOperation("获取消息提醒详细信息")
    @ApiOperationSupport(order = 3)
    @PreAuthorize("@ss.hasPermi('msg:remind:query')")
    @GetMapping("/get/{id}")
    public AjaxResult<MsgRemind> getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(msgRemindService.selectMsgRemindById(id));
    }

    @ApiOperation("新增消息提醒")
    @ApiOperationSupport(order = 4)
    @PreAuthorize("@ss.hasPermi('msg:remind:add')")
    @Log(title = "消息提醒", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody MsgRemind msgRemind) {
        return toAjax(msgRemindService.insertMsgRemind(msgRemind));
    }

    @ApiOperation("修改消息提醒")
    @ApiOperationSupport(order = 5)
    @PreAuthorize("@ss.hasPermi('msg:remind:edit')")
    @Log(title = "消息提醒", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody MsgRemind msgRemind) {
        return toAjax(msgRemindService.updateMsgRemind(msgRemind));
    }

    @ApiOperation("删除消息提醒")
    @ApiOperationSupport(order = 6)
    @PreAuthorize("@ss.hasPermi('msg:remind:remove')")
    @Log(title = "消息提醒", businessType = BusinessType.DELETE)
	@PostMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(msgRemindService.deleteMsgRemindByIds(ids));
    }

    @ApiOperation("查询消息数")
    @GetMapping("/getMsgCount")
    public AjaxResult getMsgCount() {
        return AjaxResult.success(msgRemindService.getMsgCount());
    }

    @ApiOperation("一键处理")
    @PostMapping("/oneHandle")
    public AjaxResult oneHandle(@RequestBody MsgRemind msgRemind) {
        return toAjax(msgRemindService.oneHandle(msgRemind));
    }
}
